
    <!DOCTYPE html>
    <html lang="zh-CN">
    <head>
      <meta charset="UTF-8">
      <meta name="viewport" content="width=device-width, initial-scale=1.0">
      <title>Nginx - 学习卡片</title>
      <style>
        body { font-family: sans-serif; background-color: #f0f8ff; color: #333; display: flex; flex-direction: column; align-items: center; padding: 50px 20px; }
        .header h1 { font-size: 32px; }
        .grid-container { display: grid; grid-template-columns: repeat(3, 1fr); gap: 28px; width: 100%; max-width: 1200px; }
        .card-container { perspective: 1200px; cursor: pointer; height: 250px; }
        .card { width: 100%; height: 100%; position: relative; transform-style: preserve-3d; transition: transform 0.7s; border-radius: 16px; box-shadow: 0 4px 16px rgba(0,0,0,0.08); }
        .card-container.flipped .card { transform: rotateY(180deg); }
        .card-face { position: absolute; width: 100%; height: 100%; backface-visibility: hidden; display: flex; flex-direction: column; box-sizing: border-box; border-radius: 16px; background-color: #fff; padding: 24px; }
        .card-back { background-color: #f0fff4; transform: rotateY(180deg); justify-content: space-between; }
        .card-category { font-size: 14px; color: #0052d9; margin-bottom: 8px; font-weight: 500; }
        .card-question { font-size: 20px; font-weight: 500; flex-grow: 1; display: flex; align-items: center; justify-content: center; text-align: center; }
        .card-answer-wrapper { flex-grow: 1; overflow-y: auto; }
        .card-answer { font-size: 15px; line-height: 1.7; }
        .card-footer { font-size: 13px; color: #8a919f; border-top: 1px solid #f0f0f0; padding-top: 16px; margin-top: 16px; }
        .card-source { font-size: 13px; color: #8a919f; border-top: 1px solid #f0f0f0; padding-top: 12px; margin-top: 12px; }
      </style>
    </head>
    <body>
      <div class="header">
        <h1>Nginx - 学习卡片</h1>
      </div>
      <div class="grid-container">
        
    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">理论</div>
          <div class="card-question">Nginx除了作为高性能的Web服务器外，还可以扮演哪些核心角色？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">理论</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">Nginx还可以作为反向代理服务器、负载均衡器和HTTP缓存服务器使用。</div>
          </div>
          <div class="card-source">来源: Nginx概述</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">机制</div>
          <div class="card-question">Nginx能够处理大量并发连接且系统资源消耗较低，其核心架构是什么？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">机制</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">Nginx采用了事件驱动的异步非阻塞架构，这使其能够在处理大量并发连接的同时，保持较低的系统资源消耗。</div>
          </div>
          <div class="card-source">来源: Nginx的特点</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">理论</div>
          <div class="card-question">请阐述正向代理与反向代理在代理对象和客户端感知上的核心区别。</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">理论</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">正向代理是为客户端做代理，客户端清楚地知道要访问的目标服务器。而反向代理是为服务端做代理，客户端并不知道请求最终会由哪一台具体的服务器处理。</div>
          </div>
          <div class="card-source">来源: 正向代理 / 反向代理</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">技术</div>
          <div class="card-question">Nginx内置了哪些负载均衡策略？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">技术</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">Nginx提供的内置负载均衡策略主要有三种：轮询（默认策略）、权重（weight）和Ip hash。</div>
          </div>
          <div class="card-source">来源: 负载均衡</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">模式</div>
          <div class="card-question">在Web服务器架构中，“动静分离”指的是什么？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">模式</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">动静分离是指在Web服务器架构中，将静态页面与动态页面，或者静态内容接口和动态内容接口分开，由不同的系统来访问的设计方法，目的是提升整个服务的访问性能和可维护性。</div>
          </div>
          <div class="card-source">来源: 动静分离</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">机制</div>
          <div class="card-question">Nginx的进程模型中，Master进程和Worker进程各自的主要职责是什么？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">机制</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">Master进程主要负责管理Worker进程，包括：接收外部信号、向Worker进程发送信号、监控Worker进程状态以及在Worker异常退出后自动重启新的Worker进程。而Worker进程的主要职责是处理实际的网络请求。</div>
          </div>
          <div class="card-source">来源: Nginx的进程模型 / Master进程 / work进程</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">配置</div>
          <div class="card-question">在配置Nginx静态资源代理时，`root`和`alias`指令在路径处理上有何关键区别？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">配置</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">主要区别在于路径拼接方式：`root`会将location匹配的URI附加到其指定的路径后面进行查找；而`alias`则会用其指定的路径直接替换掉location匹配的URI部分。此外，`alias`指令的路径后面必须以“/”结束，而`root`则没有这个要求。</div>
          </div>
          <div class="card-source">来源: Nginx动静分离【重点】 / root 和alias指令区</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">机制</div>
          <div class="card-question">Nginx是如何结合Keepalived来实现高可用性（HA）的？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">机制</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">通过部署一台主（Master）和一台备（Backup）Nginx服务器，并使用Keepalived在这两台服务器基础上创建一台虚拟服务器。虚拟服务器会将请求首先交给主服务器处理，当主服务器宕机时，Keepalived会自动将请求故障转移到备服务器处理，从而实现高可用。</div>
          </div>
          <div class="card-source">来源: Nginx高可用 / Nginx如何解决高可用的</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">技术</div>
          <div class="card-question">Ip hash负载均衡策略的工作原理是什么？它通常被用来解决什么问题？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">技术</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">Ip hash策略通过对客户端请求的IP地址进行哈希计算，然后根据哈希结果将来自同一个客户端IP的请求固定地分发给同一台后端服务器处理。这种机制可以有效解决多台后端服务器之间Session不共享的问题。</div>
          </div>
          <div class="card-source">来源: 负载均衡</div>
        </div>
      </div>
    </div>

      </div>
    </body>
    </html>
